﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Display {
    import flash.events.*;
    import Engine.Managers.*;
    import flash.display.*;
    import Engine.*;

    public class SlotDialog extends SWFDialog {

        protected var m_window:MovieClip;
        protected var m_data:Array;
        protected var m_tileSet:int = 0;
        protected var m_tiles:Array;

        public function SlotDialog(){
            this.m_data = [];
            this.m_tiles = new Array();
            super(true);
        }
        protected function fixArrows():void{
            this.m_window.arrowLt_bt.visible = ((this.m_tileSet)>0) ? true : false;
            this.m_window.arrowRt_bt.visible = ((((this.m_tileSet + 1) * this.getNumSlots()))<this.m_data.length) ? true : false;
        }
        protected function onLtArrowClick(_arg1:MouseEvent):void{
            var _local2:int;
            var _local3:int;
            SoundManager.chooseAndPlaySound(["click1", "click2", "click3"]);
            if (this.m_tileSet > 0){
                this.removeTiles();
                this.m_tileSet--;
                _local2 = (this.m_tileSet * this.getNumSlots());
                _local3 = 0;
                while (_local3 < this.getNumSlots()) {
                    this.addComponent(_local3, _local2);
                    _local3++;
                };
            };
            this.fixArrows();
        }
        protected function onRtArrowClick(_arg1:MouseEvent):void{
            var _local2:int;
            var _local3:int;
            SoundManager.chooseAndPlaySound(["click1", "click2", "click3"]);
            if (this.m_data.length > ((this.m_tileSet + 1) * this.getNumSlots())){
                this.removeTiles();
                this.m_tileSet++;
                _local2 = (this.m_tileSet * this.getNumSlots());
                _local3 = 0;
                while (_local3 < this.getNumSlots()) {
                    this.addComponent(_local3, _local2);
                    _local3++;
                };
            };
            this.fixArrows();
        }
        public function refreshLayout():void{
            this.removeTiles();
            var _local1:int = (this.m_tileSet * this.getNumSlots());
            var _local2:int;
            while ((((_local2 < this.getNumSlots())) && (((_local1 + _local2) < this.m_data.length)))) {
                this.addComponent(_local2, _local1);
                _local2++;
            };
            this.fixArrows();
        }
        protected function removeTiles(_arg1:Boolean=true):void{
            var _local2:int;
            while (_local2 < this.getNumSlots()) {
                if (_arg1){
                    Utilities.removeAllChildren(this.m_tiles[_local2].icon);
                    this.m_tiles[_local2].visible = false;
                    this.postRemoveTiles(_local2);
                };
                _local2++;
            };
        }
        protected function addComponent(_arg1:int, _arg2:int=0):void{
            throw (new Error("This function needs to be overriden"));
        }
        protected function postRemoveTiles(_arg1:int):void{
        }
        protected function getNumSlots():int{
            throw (new Error("This function needs to be overriden"));
        }

    }
}//package Display 
